/**
 * 
 */
package com.mobile2you.nci.android.domain;

import org.json.JSONException;
import org.json.JSONObject;

import android.graphics.Bitmap;

/**
 * @author JBromo
 * 
 */
public class News implements Comparable<News> {

	private String create;
	private String id;
	private int image;
	private String text;
	private String title;
	private String update;

	private Bitmap bitmap;

	/*
	 * (non-Javadoc)
	 * 
	 * @see java.lang.Comparable#compareTo(java.lang.Object)
	 */
	@Override
	public int compareTo(News another) {
		// TODO Auto-generated method stub
		return update.compareTo(another.toString());
	}

	/**
	 * @return the bitmap
	 */
	public Bitmap getBitmap() {
		return bitmap;
	}

	/**
	 * @return the create
	 */
	public String getCreate() {
		return create;
	}

	/**
	 * @return the id
	 */
	public String getId() {
		return id;
	}

	/**
	 * @return the image
	 */
	public int getImage() {
		return image;
	}

	public String getImageUrl() {
		return "http://nci.m2y.fr/images/news/" + image;
	}

	/**
	 * @return the text
	 */
	public String getText() {
		return text;
	}

	/**
	 * @return the title
	 */
	public String getTitle() {
		return title;
	}

	/**
	 * @return the update
	 */
	public String getUpdate() {
		return update;
	}

	public void set(JSONObject object) throws JSONException {

		create = object.getString("created_at");
		id = object.getString("id");
		image = object.getInt("image");
		text = object.getString("text");
		title = object.getString("title");
		update = object.getString("updated_at");

	}

	/**
	 * @param bitmap
	 *            the bitmap to set
	 */
	public void setBitmap(Bitmap bitmap) {
		this.bitmap = bitmap;
	}

	/**
	 * @param create
	 *            the create to set
	 */
	public void setCreate(String create) {
		this.create = create;
	}

	/**
	 * @param id
	 *            the id to set
	 */
	public void setId(String id) {
		this.id = id;
	}

	/**
	 * @param image
	 *            the image to set
	 */
	public void setImage(int image) {
		this.image = image;
	}

	/**
	 * @param text
	 *            the text to set
	 */
	public void setText(String text) {
		this.text = text;
	}

	/**
	 * @param title
	 *            the title to set
	 */
	public void setTitle(String title) {
		this.title = title;
	}

	/**
	 * @param update
	 *            the update to set
	 */
	public void setUpdate(String update) {
		this.update = update;
	}

}
